<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人和人律师事务所管理系统v1.0-律师信息查询</title>

<style type="text/css" media="all">
    .allow-float {clear:none!important;} /* 允许该元素浮动 */
    .stop-float {clear:both!important;} /* 阻止该元素浮动 */
	.float-left {float:left;padding-left:5px}   /*浮动到左边*/
  </style>
  
<script type="text/javascript">

Ext.onReady(function(){
	//删除律师信息窗口
	var modifyWin;
	//待修改的律师信息form对象
	var modifyLawInfo;
	Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
    Ext.QuickTips.init();
	//设定超时时间
    Ext.Ajax.timeout=120000; 
    Ext.form.Field.prototype.msgTarget = 'side';
    //查询框
    var searchWindow = new Ext.form.FormPanel({
			title:'律师信息查询',
			labelSeparator :'：',//分隔符
			labelWidth : 80,//标签宽度
			bodyStyle:'padding:5',//表单边距
			frame : true,
			collapsible: true,
			height:100,
			width:window.screen.width-220,
			applyTo :'searchWin',
		
			items:[
				new Ext.form.TextField({
					fieldLabel : '律师姓名',
					id : 'lawyerName',
					name : 'lawyerName',
					width:(window.screen.width-320)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),

				new Ext.form.TextField({
					fieldLabel : '职位',
					id : 'positionName',
					name : 'positionName',
					width:(window.screen.width-320)*0.18,
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					selectOnFocus : true,//得到焦点时自动选择文本
					allowBlank : true
				}),
				
				new Ext.Button({
					text : '开始查询',
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					handler : submitMsg
				})
			]

		})
		
		//查询处理函数
	function submitMsg(){
		var lawyerName=Ext.getCmp("lawyerName").getValue();
		var positionName=Ext.getCmp("positionName").getValue();
		
		 store = new Ext.data.JsonStore({
	url:"SearchLawyerInfo.jsj?lawyerName="+lawyerName+"&positionName="+positionName,
	totalProperty: 'totalCount',
    root: 'result',
	fields:["lawyerid","lawyername","birthtime","lawyersex","politicalstatus","businessnumber","businesyear","honestarchives","lawyerphone","educationallevel","identitynumber","annsurreginfo","positionname","graduateschool","lawyeremail"]
});
		store.reload({
			params:{
				start:0,
				limit:5
				}
			});
		var colModel = new Ext.grid.ColumnModel([//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "律师ID", width: 45, dataIndex: 'lawyerid', sortable: true},
				{header: "律师姓名", width: 75, dataIndex: 'lawyername', sortable: true},
				{header: "出生年月", width: 75, dataIndex: 'birthtime', sortable: true},
				{header: "性别", width: 75, dataIndex: 'lawyersex', sortable: true},
				{header: "政治面貌", width: 75, dataIndex: 'politicalstatus', sortable: true},
				{header: "执业证号", width: 75, dataIndex: 'businessnumber', sortable: true},
				{header: "执业年限", width: 75, dataIndex: 'businesyear', sortable: true},
				{header: "诚信档案", width: 75, dataIndex: 'honestarchives', sortable: true},
				{header: "联系方式", width: 75, dataIndex: 'lawyerphone', sortable: true},
				{header: "文化程度", width: 75, dataIndex: 'educationallevel', sortable: true},
				{header: "身份证号", width: 75, dataIndex: 'identitynumber', sortable: true},
				{header: "年检注册情况", width: 75, dataIndex: 'annsurreginfo', sortable: true},
				{header: "职位名", width: 75, dataIndex: 'positionname', sortable: true},
				{header: "毕业院校", width: 75, dataIndex: 'graduateschool', sortable: true},
				{header: "邮箱", width: 75, dataIndex: 'lawyeremail', sortable: true},
				]);
				pagebar.bind(store);
				grid.reconfigure(store,colModel);
		grid.getView().refresh(true); 
	}
	
    //存储器
		var store = new Ext.data.JsonStore({
	url:"LawyerInfoRequest.jsj",
	totalProperty: 'totalCount',
	root: 'result',
	fields:["lawyerid","lawyername","birthtime","lawyersex","politicalstatus","businessnumber","businesyear","honestarchives","lawyerphone","educationallevel","identitynumber","annsurreginfo","positionname","graduateschool","lawyeremail"]
});
		store.load({
			params:{
				start:0,
				limit:5
				}
			});

	
	//创建工具栏组件
		var toolbar = new Ext.Toolbar([
			{text : '律师基本信息'},
			'-', 
			{
			text:'修改选定律师信息',
			iconCls:'option',
			disabled:true,
			handler:function(btn,pressed){
			modifyLawyerInfo();
			}
			},
			'-', 
			{
			text:'删除选定律师信息',
			iconCls:'remove',
			handler:function(btn,pressed){
			deleteLawyerInfo();
			}
			}
		]);


	//删除律师信息函数
	function deleteLawyerInfo(){
	var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('修改操作','请选择要修改的一项！');
        } else {
            deleteLawyerWin();
              Ext.getCmp("lawyerids").setValue(record.get("lawyerid"));
	}
	}


//暂存要被删除的记录ID
		var deleteID=new Ext.form.TextField({
					id : 'lawyerids',
					name : 'lawyerids',
				});
				
	
		
		//删除律师信息窗口
		var deleteLawyerWin=function(){
		Ext.MessageBox.confirm("删除","确认要删除吗？",deleteDispose)
    };
		
				
		//删除律师信息处理函数
		function deleteDispose(btn){
		if(btn=='yes'){
		var lawyerID=Ext.getCmp("lawyerids").getValue();
		var requestConfig = {
			url :'DeleteLawyerInfo.jsj?lawyerID='+lawyerID,//请求的服务器地址
			success:function(response,options){ 
                        var jsonObj=Ext.util.JSON.decode(response.responseText); 
                       Ext.MessageBox.alert("结果",jsonObj.message);
                       //重新加载数据
                       store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                       },
                       failure:function(response,ooptions){
                        var jsonObj=Ext.util.JSON.decode(response.responseText);
                       Ext.MessageBox.alert("结果",jsonObj.message);
                       }
			}
		}
		Ext.Ajax.request(requestConfig);//发送请求
		
		}
		
		
		//修改律师信息函数
		function modifyLawyerInfo(){
		
		var record = grid.getSelectionModel().getSelected();
        if (!record) {
           Ext.MessageBox.alert('修改操作','请选择要修改的一项！');
        } else {
            myFormWin();
                Ext.getCmp("lawyerid").setValue(record.get("lawyerid"));
            	Ext.getCmp("lawyername").setValue(record.get("lawyername"));
            	Ext.getCmp("birthtime").setValue(record.get("birthtime"));
            	Ext.getCmp("lawyersex").setValue(record.get("lawyersex"));
            	Ext.getCmp("politicalstatus").setValue(record.get("politicalstatus"));
            	Ext.getCmp("businessnumber").setValue(record.get("businessnumber"));
            	Ext.getCmp("honestarchives").setValue(record.get("honestarchives"));
            	Ext.getCmp("lawyerphone").setValue(record.get("lawyerphone"));
            	Ext.getCmp("educationallevel").setValue(record.get("educationallevel"));
            	Ext.getCmp("identitynumber").setValue(record.get("identitynumber"));
            	Ext.getCmp("annsurreginfo").setValue(record.get("annsurreginfo"));
            	Ext.getCmp("positionname").setValue(record.get("positionname"));
            	Ext.getCmp("graduateschool").setValue(record.get("graduateschool"));
                Ext.getCmp("lawyeremail").setValue(record.get("lawyeremail"));
        }
		}
		
		//修改律师信息窗口
		var myFormWin = function() {
            modifyWin = new Ext.Window( {
                layout : 'fit',
                width : window.screen.width-600,
                height : 600,
                closeAction : 'hide',
                plain : true,
                title : '修改律师信息窗口',
                items : modifyLawInfo
            });
        modifyWin.show();
    };
    
    modifyLawInfo = new Ext.FormPanel( {
         collapsible : true,// 是否可以展开
        labelWidth : 75, // label settings here cascade unless overridden
        url : 'ModifyLawyerInfo.jsj',
        frame : true,
        title : 'modify',
        bodyStyle : 'padding:5px 5px 0',
        waitMsgTarget : true,
        
        defaults : {
            width : 230
        },
        defaultType : 'textfield',
        items : [  
        {
            fieldLabel : '律师ID',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'lawyerid',
            readOnly:true,
             id :'lawyerid',
            allowBlank :false
        }, 
        {
            fieldLabel : '律师姓名',
            itemCls:'float-left',//向左浮动
			clearCls:'allow-float',//允许浮动
            name :'lawyername',
             id :'lawyername',
            allowBlank :false
        }, 
        {
                   fieldLabel :'出生年月',
					id :'birthtime',
					name :'birthtime',
					itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
					allowBlank :true
        },
        {
            fieldLabel : '性别',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'lawyersex',
            id:"lawyersex",
            allowBlank : false
        },
        {
            fieldLabel : '政治面貌',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'politicalstatus',
            id:"politicalstatus",
            allowBlank : false
        },
        {
            fieldLabel : '执业证号',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'businessnumber',
            id:"businessnumber",
            allowBlank : false
        },
         {
            fieldLabel : '诚信档案',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'honestarchives',
            id:"honestarchives",
            allowBlank : false
        },
        {
            fieldLabel : '联系方式',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'lawyerphone',
            id:"lawyerphone",
            allowBlank : false
        },
        {
            fieldLabel : '文化程度',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'educationallevel',
            id:"educationallevel",
            allowBlank : false
        },
         {
            fieldLabel : '身份证号',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'identitynumber',
            id:"identitynumber",
            allowBlank : false
        },
         {
            fieldLabel : '年检注册情况',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'annsurreginfo',
            id:"annsurreginfo",
            allowBlank : false
        },
         {
            fieldLabel : '职位名',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'positionname',
            id:"positionname",
            allowBlank : false
        },
         {
            fieldLabel : '毕业院校',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'graduateschool',
            id:"graduateschool",
            allowBlank : false
        },
         {
            fieldLabel : '邮箱',
            itemCls:'float-left',//向左浮动
					clearCls:'allow-float',//允许浮动
            name :'lawyeremail',
            id:"lawyeremail",
            allowBlank : false
        }
        ],

        buttons : [ {
            text : '保存',
            disabled : false,
            handler : function() {
                if (modifyLawInfo.form.isValid()) {
                    modifyLawInfo.form.submit( {
                        url : 'ModifyLawyerInfo.jsj',
                        success : function(from, action) {
                         Ext.MessageBox.alert('保存成功', '修改律师信息成功！');
                            store.load( {
                                params : {
                                    start : 0,
                                    limit : 5
                                }
                            });
                            modifyWin.hide();
                        },
                        failure : function(form, action) {
                           Ext.MessageBox.alert('保存失败', '修改律师信息失败！');
                        },
                        waitMsg : '正在保存数据，稍后...'
                    });
                   // dialog.hide();
                } else {
                    Ext.Msg.alert('信息', '请填写完成再提交!');
                }
            }
        }, {
            text : '取消',
            handler : function() {
                modifyWin.hide();
            }
        }]
    });
    
    
		//分页工具栏
		var pagebar = new Ext.PagingToolbar({
			store : store,
			pageSize : 5,
			displayInfo : true,
			displayMsg : '第 {0} ~ {1} 条 共 {2} 条',
			emptyMsg : '当前没有记录'
		});
		//创建选择模式对象
	var cb = new Ext.grid.CheckboxSelectionModel()
	//创建Grid表格组件
	var grid = new Ext.grid.GridPanel({
			renderTo : 'grid-div',
			frame : true,
			tbar : toolbar,
			bbar : pagebar,
			trackMouseOver:true, //鼠标特效
			loadMask: true,    //是否显示正在加载
			store : store,
			height : 320,
			width : window.screen.width-220,
			stripeRows : true,
			autoScroll : true,
			viewConfig : {autoFill : true},
			sm : cb,
			columns: [//配置表格列
				new Ext.grid.RowNumberer({
					header : '行号',
					width : 40
				}),
				cb,
				{header: "律师ID", width: 45, dataIndex: 'lawyerid', sortable: true},
				{header: "律师姓名", width: 75, dataIndex: 'lawyername', sortable: true},
				{header: "出生年月", width: 75, dataIndex: 'birthtime', sortable: true},
				{header: "性别", width: 75, dataIndex: 'lawyersex', sortable: true},
				{header: "政治面貌", width: 75, dataIndex: 'politicalstatus', sortable: true},
				{header: "执业证号", width: 75, dataIndex: 'businessnumber', sortable: true},
				{header: "执业年限", width: 75, dataIndex: 'businesyear', sortable: true},
				{header: "诚信档案", width: 75, dataIndex: 'honestarchives', sortable: true},
				{header: "联系方式", width: 75, dataIndex: 'lawyerphone', sortable: true},
				{header: "文化程度", width: 75, dataIndex: 'educationallevel', sortable: true},
				{header: "身份证号", width: 75, dataIndex: 'identitynumber', sortable: true},
				{header: "年检注册情况", width: 75, dataIndex: 'annsurreginfo', sortable: true},
				{header: "职位名", width: 75, dataIndex: 'positionname', sortable: true},
				{header: "毕业院校", width: 75, dataIndex: 'graduateschool', sortable: true},
				{header: "邮箱", width: 75, dataIndex: 'lawyeremail', sortable: true},
				]
		});
});

</script>
</head>
<body>
<table><tr><td>
<div id='searchWin' style="margin:8px 8px 4px 8px"></div>
</td></tr>
</table>
<div id='grid-div' style="margin:4px 8px 8px 8px"></div>


</body>
</html>